Skip to content

Use graphql-java's TypeUtil to unwrap and print SDL types - #871

Merged
oryan-block merged 1 commit into
masterfrom
cleanup/type-util
Oct 18, 2026
Merged

oryan-block merged 1 commit into
masterfrom
cleanup/type-util

Conversation

@oryan-block

Copy link
Copy Markdown
Collaborator

Checklist

  • Pull requests follows the contribution guide
  • New or modified functionality is covered by tests

Description

Our Type<*>.unwrap() returned Type<*>, so most callers cast the result to TypeName even though an unwrapped SDL type is always a TypeName. It now returns TypeName through graphql-java's TypeUtil.unwrapAll, which drops those casts and a !is TypeName check that could never be true.

Same thing in UnmappedInputFieldChecker#inputObjectOf: GraphQLTypeUtil.unwrapAllAs can return a GraphQLNamedType directly since every unwrapped schema type has a name, type references included.

TypeUtil isn't annotated @PublicApi, but it's been in graphql-java since at least 20.0.

The only behaviour change is the type matcher's error message, which now prints the SDL type with TypeUtil.simplePrint. For a [Book!]! field whose resolver returns a single Book:

Unable to match type definition (NonNullType{type=ListType{type=NonNullType{type=TypeName{name='Book'}}}}) for reference ...

becomes

Unable to match type definition ([Book!]!) for reference ...

GraphQLTypeUtil itself didn't help much elsewhere since most of our code works on SDL types, not schema types.

mvn clean verify passes against graphql-java 26.1 and 25.1. I also ran every verify-tools scenario on this branch and on master: same schemas, results and logs, except the error message above.

@sonarqubecloud

Copy link
Copy Markdown

@oryan-block
oryan-block merged commit 8f7575d into master Oct 18, 2026
7 checks passed
@oryan-block
oryan-block deleted the cleanup/type-util branch October 18, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant